// 某一赛项参赛队伍，及其参赛人员表格
const { Model, DataTypes } = require('sequelize');

const sequelize = require('./database');
const User = require('./user');
const Staff = require('./staff');
const Team = require('./projectteam');

class TeamStaff extends Model {}
// 队伍成员数据表
TeamStaff.init({

  teamId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment:"赛项队伍ID",
    allowNull: false,
    references: {
      model: Team, // 指定关联的模型
      key: 'id'
    }
  },
  userId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: User, // 指定关联的模型
      key: 'id'
    }
  },
  staffId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment:"运动员ID",
    references: {
      model: Staff, // 指定关联的模型
      key: 'id'
    }
  }
}, {
  sequelize,
  modelName: 'teamstaff'
});
TeamStaff.belongsTo(Staff,{ foreignKey: 'staffId' })
TeamStaff.belongsTo(User,{ foreignKey: 'userId' })
TeamStaff.belongsTo(Team,{ foreignKey: 'teamId' })
module.exports = TeamStaff;